﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace DataShow.codeDAL
{
    public class SceneProcess
    {

        #region 构造函数
        SqlHelper sqlhelper;
        public SceneProcess()
        {
            sqlhelper = new SqlHelper();
        } 
        #endregion

        #region 搜索降雨量
        /// <summary>
        /// 搜索降雨量
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="timeBegin">起始时间</param>
        /// <param name="timeEnd">结束时间</param>
        /// <param name="types"></param>
        /// <param name="stations"></param>
        /// <returns></returns>
        public DataTable SearchRain(string tableName,int pagesize, int pageindex, string condition )
        {
            return new Common().Search(tableName, pagesize, pageindex, condition, "*","date,type");
        } 
        #endregion

        #region 搜索气温
        /// <summary>
        /// 搜索气温
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="timeBegin">起始时间</param>
        /// <param name="timeEnd">结束时间</param>
        /// <param name="types"></param>
        /// <param name="stations"></param>
        /// <returns></returns>
        public DataTable SearchTemp(string tableName, int pagesize, int pageindex, string condition)
        {
            return new Common().Search(tableName, pagesize, pageindex, condition, "*","date,type");
        }
        #endregion

        #region 计算总页数
        /// <summary>
        /// 计算总页数
        /// </summary>
        /// <param name="table"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public DataTable CalculateCount(string table, string condition,string mode = "value")
        {
            string sql = "";
            if (mode == "value")
            {
                sql = "select * from " + table + " where " + condition;
            }
            else
            {
                sql = "select * from " + table + " where " + condition+" and semi <> ''";
            }
            return sqlhelper.ExecuteQuery(sql, CommandType.Text);
        } 
        #endregion
    }
}